package com.example.saiweisi.controller.userController;

import com.example.saiweisi.common.Result;
import com.example.saiweisi.controller.request.*;
import com.example.saiweisi.service.interf.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/order")
@RestController
@CrossOrigin
@Slf4j
public class OrderController {
    @Autowired
    IOrderService orderService;

    /**
     * 根据用户id查所有订单
     *
     * @param historyOrderRequest 每页条数，第几页、用户id
     * @return 一个pageinfo，分页将查询到的订单信息返回
     */
    @GetMapping("/history")
    public Result getHistoryOrder(HistoryOrderRequest historyOrderRequest) {
        return Result.success(orderService.getHistoryOrder(historyOrderRequest));
    }


    @GetMapping("/all")
    public Result getAllOrder(PageBaseRequest pageBaseRequest) {
        return Result.success(orderService.getAllOrder(pageBaseRequest));
    }
    @GetMapping("/yuyue")
    public Result getyuyueOrder(YuyueOrderRequest yuyueOrderRequest) {
        return Result.success(orderService.getyuyueOrder(yuyueOrderRequest));
    }
    /**
     * 对订单进行假删除
     *
     * @param orderId 订单的id
     * @return 成功信息
     */
    @DeleteMapping("/delete{orderId}")
    public Result deleteorder(@PathVariable Integer orderId) {
        orderService.deleteOrder(orderId);
        return Result.success();
    }

    /**
     * 支付
     * @param orderId 订单id
     * @return 成功信息
     */
    @PutMapping("/pay{orderId}")
    public Result payOrder(@PathVariable Integer orderId) {
        orderService.payOrder(orderId);
        return Result.success();
    }
//
//    /**
//     * 确认送洗
//     * @param orderId 订单id
//     * @return Result.success() 成功信息
//     */
//    @PutMapping("/confrimWashing{orderId}")
//    public Result confrimWashing(@PathVariable Integer orderId) {
//        orderService.confrimWashing(orderId);
//        return Result.success();
//    }
//
//    /**
//     * 确认取衣
//     * @param orderId 订单id
//     * @return Result.success() 成功信息
//     */
//    @PutMapping("/confrimTaking{orderId}")
//    public Result confrimTaking(@PathVariable Integer orderId) {
//        orderService.confrimTaking(orderId);
//        return Result.success();
//    }
    /**
     * 获取订单详情
     * @param orderInfoRequest 订单id
     * @return 订单详情
     */
    @GetMapping("/info")
    public Result getOrderInfo(OrderInfoRequest orderInfoRequest) {
        return Result.success(orderService.getOrderInfo(orderInfoRequest));
    }
//
//    @PostMapping("/submit/{userId}/{orderPrice}/{orderPriceZhe}")
//    public Result submitOrder(@PathVariable Integer userId, @PathVariable Double orderPrice,
//                              @PathVariable Double orderPriceZhe, @RequestBody List<OrderRequest> orderRequest) {
//        orderService.submitOrder(userId, orderPrice, orderPriceZhe, orderRequest);
//        return Result.success();
//    }

}
